﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global_color.css" /> 
    </head>
    <body onload="initialYearAndMonth();">
        <!--Logo区域开始-->
        <div id="header">
            <img src="../images/logo.png" alt="logo" class="left"/>
            <a href="/logout">[退出]</a>
        </div>
        <!--Logo区域结束-->
        <!--导航区域开始-->
        <div id="navi">                        
            <ul id="menu">
                <li><a href="/index" class="index_on"></a></li>
                <li><a href="/rolelist" class="role_off"></a></li>
                <li><a href="/adminList" class="admin_off"></a></li>
                <li><a href="/feelist" class="fee_off"></a></li>
                <li><a href="/accountlist" class="account_off"></a></li>
                <li><a href="/servicelist" class="service_off"></a></li>
                <li><a href="/billList" class="bill_off"></a></li>
                <li><a href="/reportList" class="report_off"></a></li>
                <li><a href="/userInfo" class="information_off"></a></li>
                <li><a href="/userModiPwd" class="password_off"></a></li>
            </ul>            
        </div>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">
            <form>
                <!--查询-->
                <div class="search_add">
                </div>  
                <!--数据区域：用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                        <tr>
                            <th class="width150">客户登录 IP</th>
                            <th class="width150">登入时刻</th>
                            <th class="width150">登出时刻</th>
                            <th class="width100">时长（秒）</th>
                            <th class="width150">费用</th>
                            <th>资费</th>
                        </tr>
                    </table>
                </div>
                <!--分页-->
                <div id="pages">

                </div>                    
            </form>
        </div>
        <!--主要区域结束-->
        <div id="footer">
            <p>[源自北美的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</p>
           <p>版权所有(C)云科技有限公司 </p>
        </div>
        <script src="../../js/jquery-3.2.1.js"></script>
        <script src="../../js/GetQueryString.js"></script>
        <script src="../../js/parseDate.js"></script>
        <script>
            var costId=GetQueryString('costId');
            $.ajax({
                url: "/selectCostById",
                type: "post",
                data:{
                    costId:costId
                },
                success: function (data) {
                    for (var i in data) {
                        var service=data[i];
                        var osUsername=service.osUsername;
                        var unixHost=service.unixHost;
                        for (var j in service.cList){
                            var cList=service.cList[j];
                            var startime=cList.startime;
                            var start=getTime(startime);
                            var baseDuration=cList.baseDuration;
                            var baseCost=cList.baseCost;
                            var unitCost=cList.unitCost;
                            var name=cList.name;
                        }
                        for (var k in service.aList){
                            var aList=service.aList[k];
                            var lastLoginTime=aList.lastLoginTime;
                            var loginName = aList.loginName;
                        }
                        var lastStart=lastLoginTime-startime;
                        var timeLongSecound=(lastStart)/1000;
                        var timeLongHour=timeLongSecound/3600;
                        var spareTime=timeLongHour-baseDuration;
                        var cost=0;
                        if (spareTime>0){
                            cost=baseCost+spareTime*unitCost;
                        }else{
                            cost=baseCost;
                        }
                    }
                    $(".search_add").append("<div>账务账号：<span class='readonly width70' id='loginName'></span></div><div>OS 账号：<span class='readonly width100' id='osUsername'></span></div><div>服务器 IP：<span class='readonly width100' id='unixHost'></span></div><div>计费时间：<span class='readonly width70' id='startime'></span></div><div>费用：<span class='readonly width70' id='cost'></span></div><input type='button' value='返回' class='btn_add' onclick='returnPage("+costId+")' />");
                    $("#loginName").text(''+loginName+'');
                    $("#osUsername").text(''+osUsername+'');
                    $("#unixHost").text(''+unixHost+'');
                    $("#startime").text(''+start+'');
                    $("#cost").text(''+cost+'');
                    $("#datalist").append("<tr><td>"+unixHost+"</td><td>"+startime+"</td><td>"+lastLoginTime+"</td><td>"+timeLongSecound+"</td><td>"+cost+"</td><td>"+name+"</td></tr>");
                }
            });
            function returnPage(costId) {
                window.location.href='/billItem?costId='+costId+'';
            }
        </script>
    </body>
</html>
